From 976b2fd5170db09a34985d8d479a6d45dc214787 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Tue, 9 Feb 2021 22:21:15 +0100 Subject: [PATCH] phase1: fix gitcheckout with corrupted .git MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When the container running `git clone` is killed it will leave the .git directory in unusable state which then leads in the following errors: if [ -d .git ]; then git checkout -f master; git branch --set-upstream-to origin/master; else exit 0; fi error: pathspec 'master' did not match any file(s) known to git. fatal: branch 'master' does not exist Fix it by removing .git completely if this happens, otherwise it might simply leave shared build directory in the unusable state. Signed-off-by: Petr Å tetiar --- phase1/master.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phase1/master.cfg b/phase1/master.cfg index 7186f5a..2cba85e 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -710,7 +710,7 @@ for target in targets: factory.addStep(ShellCommand( name = "gitcheckout", description = "Ensure that Git HEAD is sane", - command = "if [ -d .git ]; then git checkout -f %s; git branch --set-upstream-to origin/%s; else exit 0; fi" %(repo_branch, repo_branch), + command = "if [ -d .git ]; then git checkout -f %s && git branch --set-upstream-to origin/%s || rm -fr .git; else exit 0; fi" %(repo_branch, repo_branch), haltOnFailure = True)) # check out the source -- 2.30.2